/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amuthu.expression.function.indicator;

import org.amuthu.DataStore;
import org.amuthu.expression.Expression;
import org.amuthu.expression.exception.InvalidArgumentException;
import org.amuthu.parser.ExpressionVisitor;

/**
 * range(exp, start, end)
 * @author prabhu
 */
public class RangeFunction extends AbstractFunctionEvaluator
{
   public double computeIndicator(DataStore dataStore, Expression[] arguments, ExpressionVisitor visitor) throws InvalidArgumentException
   {
      if (arguments.length < 3)
      {
         throw new InvalidArgumentException("ABS function zero args");
      }

      int exp = (int) visitor.evaluate(arguments[0]);
      int start = (int) visitor.evaluate(arguments[1]);
      int end = (int) visitor.evaluate(arguments[2]);

      if (exp > start && exp < end)
      {
         return 1.0;
      }
      else
      {
         return 0.0;
      }
   }

   @Override
   public boolean updateParameters(DataStore dataStore, Expression[] arguments, ExpressionVisitor visitor)
   {
      throw new UnsupportedOperationException("Not supported yet.");
   }

   public int computeDayDependency(DataStore dataStore, Expression[] arguments, ExpressionVisitor visitor) throws InvalidArgumentException
   {
      return 0;
   }

}
